/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.Group;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class ShowCustomerTotalNumChart extends AbstractAction
/*    */ {
/*    */   public ShowCustomerTotalNumChart(AbstractHttpServlet servlet)
/*    */   {
/* 31 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 41 */     User user = super.getLoginUser(request);
/* 42 */     if ((!user.isAdmin) && (!user.isGroupAdmin)) {
/* 43 */       super.showErrorMessage(response, "只有管理员或者部门经理才有查看的权限");
/* 44 */       return;
/*    */     }
/*    */ 
/* 47 */     response.setContentType("text/html;charset=utf-8");
/* 48 */     PrintWriter out = response.getWriter();
/* 49 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 51 */     int groupId = 0;
/* 52 */     if (!user.isAdmin) {
/* 53 */       groupId = user.groupId;
/*    */     }
/* 55 */     CompanyInfo comapny = super.getCompany(request);
/*    */ 
/* 57 */     String groupIds = "";
/* 58 */     if (groupId > 0) {
/* 59 */       Group group = comapny.getGroupById(groupId);
/* 60 */       if (group != null) {
/* 61 */         groupIds = group.getAllIds();
/*    */       }
/*    */ 
/* 64 */       if ((groupIds == null) || (groupIds.trim().length() == 0)) {
/* 65 */         super.showErrorMessage(response, "您选择的部门不存在");
/* 66 */         return;
/*    */       }
/*    */     }
/*    */ 
/* 70 */     CustomerManager manager = new CustomerManager();
/* 71 */     List result = manager
/* 72 */       .getCustomerTotalNumInfoByGroupIds(user.companyId, groupIds);
/* 73 */     jsonObject.put("error", "0");
/* 74 */     jsonObject.put("result", result);
/* 75 */     out.println(jsonObject);
/* 76 */     out.flush();
/* 77 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowCustomerTotalNumChart
 * JD-Core Version:    0.6.1
 */